{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

{{#if this.show}}
  <ListAccordion
    data-test-recommendation-accordion
    class="recommendation-accordion boxed-section {{if this.closing 'closing'}}"
    @source={{array @summary}}
    @key="id"
    {{did-insert this.inserted}}
    as |a|
  >
    {{#if a.isOpen}}
      <div class="animation-container" style={{this.animationContainerStyle}}>
        <Das::RecommendationCard
          @summary={{@summary}}
          @proceed={{this.proceed}}
          @onCollapse={{a.close}}
          @skipReset={{true}}
        />
      </div>
    {{else}}
      <a.head @buttonLabel={{unless a.isOpen "Show"}}>
        <section class="left">
          <Hds::Icon @name="info-fill" />
          <span>Resource Recommendation</span>
          <span data-test-group class="group">{{@summary.taskGroup.name}}</span>
        </section>

        <section class="diffs">
          {{#if this.diffs.cpu.delta}}
            <section>
              <span class="resource">CPU</span>
              {{this.diffs.cpu.signedDiff}}
              <span class="percent">{{this.diffs.cpu.percentDiff}}</span>
            </section>
          {{/if}}

          {{#if this.diffs.memory.delta}}
            <section>
              <span class="resource">Mem</span>
              {{this.diffs.memory.signedDiff}}
              <span class="percent">{{this.diffs.memory.percentDiff}}</span>
            </section>
          {{/if}}
        </section>
      </a.head>
    {{/if}}
  </ListAccordion>
{{/if}}
